all: server client

GLMLITE=../lib/glMLite-0.03.50/SRC
OCAML_CHIPMUNK=../lib/OCaml-Chipmunk-0.05
CHIPMUNK=../lib/Chipmunk-5.3.4/src

LIBS=chipmunk.cmxa GL.cmxa Glu.cmxa Glut.cmxa str.cmxa unix.cmxa threads.cmxa -cclib -lGL
INCLUDES=-I $(GLMLITE) -I $(OCAML_CHIPMUNK) -ccopt -L$(GLMLITE) -ccopt -L$(OCAML_CHIPMUNK) -ccopt -L$(CHIPMUNK)

libs:
	cd $(CHIPMUNK)/.. && cmake .
	make -C $(CHIPMUNK)/..
	make -C $(GLMLITE)/..
	make -C $(OCAML_CHIPMUNK)

server: Types.cmx Config.cmx Player.cmx Object.cmx Collision.cmx GameEngine.cmx Parser.cmx Lexer.cmx Script.cmx Server.cmx
	ocamlopt -thread $(INCLUDES) $(LIBS) -o $@ $+

client: Types.cmx Config.cmx Player.cmx Object.cmx Widgets.cmx Client.cmx
	ocamlopt -thread $(INCLUDES) $(LIBS) -o $@ $+

script: Types.cmx Parser.cmx Lexer.cmx Script.cmx 
	ocamlopt -thread $(INCLUDES) $(LIBS) -o $@ $+

Lexer.cmx:
	ocamllex Lexer.mll
	ocamlopt -c Lexer.ml

Parser.cmx:
	ocamlyacc Parser.mly
	ocamlopt -c Parser.mli
	ocamlopt -c Parser.ml

%.cmx: %.ml
	ocamlopt -thread $(INCLUDES) $(LIBS) -c -o $@ $+

clean:
	rm -f *.cmx *.cmi *.cmx

